/**
 * \file Mutex.h
 * \brief Mutex definition class for Linux platforms
 * \author Edouard ROGE
 * \date 01 September 2012
 */

#ifndef _MUTEX_LINUX_
#define _MUTEX_LINUX_

#include <pthread.h>
#include "Core/Error/Error.h"

/**
 * \class Mutex
 * \brief Needed when several Tasks need to write in the same object to avoid conflicts
 * @see Task
 */
class Mutex
{
public:
	/**
	 * \fn Mutex();
	 * \brief Default constructor
	 */
	Mutex();

	/**
	 * \fn virtual ~Mutex();
	 * \brief Destructor
	 */
	virtual ~Mutex();

	/**
	 * \fn error Lock();
	 * \return Returns if the mutex is correctly locked
	 * \brief Lock the mutex to keep the right of writing
	 */
	error Lock();

	/**
	 * \fn error Unlock();
	 * \return Returns if the mutex is correctly released
	 * \brief Release the mutex to allow other tasks to write
	 */
	 error Unlock();

private:

	/** the mutex */
	pthread_mutex_t m_Mutex;
};

#endif // _MUTEX_LINUX_
